package org.zxp.thread.ccontainer;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @program: zxp-thread-test
 * @description: 测试ArrayBlockingQueue
 * @author: X-Pacific zhang
 * @create: 2019-05-30 15:59
 **/
public class ArrayBlockingQueueTest {
    public static void main(String[] args) throws InterruptedException {
        //有界
        ArrayBlockingQueue<String> queue = new ArrayBlockingQueue(1024);
        for (int i = 0;i < 1000;i++){
            new Thread(() -> {
                queue.add("i");
            }).start();
        }
        Thread.sleep(1000L);
        System.out.println(queue.size());//结果为是线程安全的
    }
}
